package qmlt.dataset;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

public class Attribute
{
	public static final String	STRING	= "string";

	public static final String	FLOAT		= "float";

	// available types: string, float
	public final String					type;

	public final String					noValueString;

	public List<Object>					validValues;

	public Attribute(String type, String noValueString)
	{
		this.type = type;
		this.noValueString = noValueString;
	}

	public Attribute(JSONObject obj) throws JSONException
	{
		type = obj.getString("type");
		noValueString = obj.optString("no-value");
	}

	@Override
	public String toString()
	{
		return String.format("type:%s%s", type, (noValueString == null || noValueString.isEmpty() ? ""
				: ",no-value:" + noValueString));
	}
}
